﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WindowsGame4
{
    class Bomb_DestroyState : State
    {
        private static Bomb_DestroyState instance;

        private Bomb_DestroyState()
        {
            base.Name = "DestroyState";
        }

        public override void enter(AIObject aiObject)
        {
            AIBomb aiBomb = (AIBomb)aiObject;
            Bomb bomb = (Bomb)aiBomb.Bomb;
            GameInfo gameInfo = GameInfo.getInstance();
         
            int row = gameInfo.World.getNumRow(bomb.Position.Y);
            int column = gameInfo.World.getNumColumn(bomb.Position.X);

  
            bomb.Visible = false;
            //aiBomb.Bomb.changeAnimation("explosion");
            EventEmitter.getInstance().registerMessage(0, aiBomb.Id, aiBomb.Id, Message.MessageType.msg_remove);
            if (Game1.enableMusic)
                Game1.bombExplosion.Play();   

            gameInfo.createExplosions(bomb.Position.X, bomb.Position.Y, bomb.Distance, bomb.IdEmitter);
           
        }

        public static Bomb_DestroyState getInstance()
        {
            if (instance == null)
                instance = new Bomb_DestroyState();
            return instance;
        }

        public override void execute(AIObject aiObject)
        {
        }

        public override void exit(AIObject aiObject)
        {
        }

        public override Boolean onMessage(AIObject aiObject, Message message)
        {
            Boolean correct = false;
            switch (message.Type)
            {
                case Message.MessageType.msg_remove:
                    {

                        GameInfo.getInstance().removeObject(aiObject.Id, Object.TypeObject.bomb);
                        correct = true;
                        break;
                    }
            }
            return correct;
        }
    }
}
